// template.js

module.exports = {
    vueTemplate: compoenntName => {
        return `<template>
<div class="${compoenntName}" id="app">
</div>
</template>
<script>
export default {
  name: '${compoenntName}',
  data () {
    return {
    }
  },
  created () {},
  mounted () {},
  methods: {
  }
}
</script>
<style scoped>
</style>
`
    },
    entryTemplate: compoenntName => {
        const vueinputName = compoenntName.charAt(0).toUpperCase() + compoenntName.slice(1)
        return `import zzb from 'zzbjssdk'
import ${vueinputName} from './${vueinputName}.vue'
import Vue from 'vue'
Vue.directive('real-img', async function (el, binding) { // 指令名称为：real-img
  let imgURL = binding.value // 获取图片地址
  if (imgURL) {
    let exist = await imageIsExist(imgURL)
    if (exist) {
      el.setAttribute('src', imgURL)
    }
  }
})
let imageIsExist = function (url) {
  return new Promise((resolve) => {
    var img = new Image()
    img.onload = function () {
      if (this.complete === true) {
        resolve(true)
        img = null
      }
    }
    img.onerror = function () {
      resolve(false)
      img = null
    }
    img.src = url
  })
}
zzb.vue({
  el: '#app',
  components: { ${vueinputName} },
  template: '<${vueinputName}/>'
})
`
    },
    jsonTemplate: compoenntName => {
        return '{' +
            '"title": "",' +
            '"topBarVisible": true,' +
            '"statusColor": "",' +
            '"isBlack":false'+
            '}'
    }
}
